package com.dtx.datastruct.stack.linkedlist;

import java.util.Iterator;
import java.util.LinkedList;

public class LinkedListStack<E> {

    private LinkedList<E> stack;

    public LinkedListStack() {
        stack = new LinkedList<>();
    }

    public void push(E item){
          stack.addFirst(item);
    }

    public boolean isEmpty(){
        return stack.size() == 0;
    }

    public E pop(){
       return stack.poll();
    }

    public E peek(){
        return stack.peek();
    }

    public void printStack(){
        stack.stream().forEach(System.out::println);
    }



    public static void main(String[] args) {
        LinkedListStack<String> s1 = new LinkedListStack<>();
        s1.push("A");
        s1.push("B");
        s1.push("C");
        s1.printStack();
        System.out.println("==================");
        System.out.println(s1.pop());
        System.out.println("==================");
        s1.printStack();
    }
}
